<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-cn">
<head>
	<meta charset="UTF-8">
	<title>系统后台 - <?php echo (C("INTENDANT_NAME")); ?> - by HemaCMS</title>
	<link href="/Public/intendant/css/index_layout.css" rel="stylesheet" />
	<script src="/Public/common/js/jquery.js"></script>
	<script src="/Public/common/js/jquery.cookie.js"></script>
	<script src="/Public/intendant/js/iteny.intendant.js"></script> <!-- 公共easyui JS -->
  <script src="/Public/common/js/layer/layer.js"></script>
  <link href="/Public/intendant/css/icons.css" rel="stylesheet" />
  <link href="/Public/intendant/css/iteny.css" rel="stylesheet" />
	<style>
.fullScreen .content th {
	display: none;
	width: 0;
}
.fullScreen .head, .fullScreen .tab {
	height: 0;
	display: none;
}
.fullScreen #default {
        *left:0;
        *top:-90px;
}
.fullScreen div.options {
	top: 0;
}
</style>
</head>
<body>
<div class="wrap">
  <!-- <noscript>
  <h1 class="noscript">您已禁用脚本，这样会导致页面不可用，请启用脚本后刷新页面</h1>
  </noscript> -->
  <table width="100%" height="100%" style="table-layout:fixed;">
    <tr class="head">
      <th><a href="<?php echo U('Index/index');?>" class="logo"><img src="/Public/intendant/images/logo.png" style="width:140px; height=40px;display:inline-block;" />管理中心</a></th>
      <td><div class="nav">
          <!-- 菜单异步获取，采用json格式，由js处理菜单展示结构 -->
          <ul id="J_B_main_block">
          	<?php if(is_array($topNav)): foreach($topNav as $key=>$topnav): ?><li><a class="top-nav" href="javascript:void(0);" title="<?php echo ($topnav["title"]); ?>" data-click='true' data-id="<?php echo ($topnav["id"]); ?>" data-url='<?php echo U("Index/getLeftMenu");?>'><?php echo ($topnav["title"]); ?></a></li><?php endforeach; endif; ?>

          </ul>
        </div>
        <div class="login_info">
        	<a  class="home"><?php echo (session('admin_group')); ?>&nbsp;:&nbsp;<?php echo (session('admin_user')); ?> </a>

        	<a href="<?php echo U('Home/Index/index');?>" class="home" target="_blank">前台首页</a>
        	<a href="<?php echo U('Index/deleteCache');?>" id="deletecache" class="home">缓存更新</a>
        	<a href="javascript:;;" id="zhuti" class="home" >主题风格</a>
        	<a href="<?php echo U('Index/logout');?>" class="home out">退出</a>
        </div>
      </td>

    </tr>
    <tr class="tab">
      <th> <div class="search">
          <input style="line-height: 19px;" size="15" placeholder="搜索功能模块" id="J_search_keyword" data="<?php echo U('Login/index');?>" type="text">
          <button type="button" name="keyword" id="J_search" value="" data-url="">搜索</button>
        </div></th>
      <td><div id="B_tabA" class="tabA"> <a href="" tabindex="-1" class="tabA_pre" id="J_prev" title="上一页">上一页</a> <a href="" tabindex="-1" class="tabA_next" id="J_next" title="下一页">下一页</a>
          <div style="margin:0 25px;min-height:1px;">
            <div style="position:relative;height:36px;width:100%;overflow:hidden;">
              <ul id="B_history" style="white-space:nowrap;position:absolute;left:0;top:0;">
                <li class="current" data-id="default" tabindex="0"><span><a>后台首页</a></span></li>
              </ul>
            </div>
          </div>
        </div></td>
    </tr>
    <tr class="content">
      <th  style="overflow:hidden;border-right: 2px solid #dedede;">
        <div id="B_menunav" style="margin-top: 0px">
          <div class="menubar">
            <dl id="B_menubar" data-id="3Admin"></dl>
          </div>
          <div id="menu_next" class="menuNext" style="display:none;"> <a href="" class="pre" title="顶部超出，点击向下滚动">向下滚动</a> <a href="" class="next" title="高度超出，点击向上滚动">向上滚动</a> </div>
        </div>
      </th>
      <td id="B_frame" style="height:100%;">
        <div class="options"> <a href="" class="refresh" id="J_refresh" title="刷新">刷新</a> <a href="" id="J_fullScreen" class="full_screen" title="全屏">全屏</a> </div>
        <!-- <div class="loading" id="loading">加载中...</div> -->
        <iframe id="iframe_default" src="<?php echo U('Index/home');?>" style="height: 100%; width: 100%;display:block;" data-id="default" frameborder="0" scrolling="auto"></iframe></td>
    </tr>
  </table>
</div>


</body>
</html>
<script>

$(function(){
    $('#deletecache').on('click', function (e) {
      e.preventDefault();
      var href = $(this).attr('href');
      layer.confirm('<span style="color:red;">是否真心要清空缓存</span>', {icon: 3,offset:'200px', title:'操作缓存提示'}, function(index){
          layer.close(index);
          $.ajax({
          type: 'post',
          url: href,
          // data : {id : data},
          dataType:"json",
          beforeSend: function(){
            layer.load(1);
          },
          success: function(data){
            layer.close(layer.load(1));
            if(!data.status){
              ITENY.alert('提示信息',data.info,2,'3000');

            } else {
              ITENY.alert('提示信息',data.info,1,'3000');
            }
          },
          error: function(data){
            layer.close(layer.load(1));
            ITENY.alert('提示信息',data.responseText,1,'3000');

          }
        });
      });
    });
	//不支持placeholder浏览器下对placeholder进行处理
    if (document.createElement('input').placeholder !== '') {
        $('[placeholder]').focus(function () {
            var input = $(this);
            if (input.val() == input.attr('placeholder')) {
                input.val('');
                input.removeClass('placeholder');
            }
        }).blur(function () {
            var input = $(this);
            if (input.val() == '' || input.val() == input.attr('placeholder')) {
                input.addClass('placeholder');
                input.val(input.attr('placeholder'));
            }
        }).blur().parents('form').submit(function () {
            $(this).find('[placeholder]').each(function () {
                var input = $(this);
                if (input.val() == input.attr('placeholder')) {
                    input.val('');
                }
            });
        });
    }

    //获取左侧菜单
    $(".top-nav").click(function(e) {
      // alert('111');
      ITENY.iframe_height();
      if($(this).parent('li').attr("class") == "current"){
             return false;
      }
      if($(this).attr("data-click") == "true"){
        title = $(this).text();
        var topid = $(this).attr("data-id");
        $('#J_B_main_block li').removeClass('current');
        $(this).parent('li').addClass('current');
        $.ajax({
          type: 'POST',
          url: $(this).attr('data-url'),
          data: 'pid='+$(this).attr("data-id"),
          dataType: 'json',
          beforeSend: function(){
            $('#B_menubar').html('<div class="loading" id="loading">加载中...</div>');

            // $("#leftmenu").accordion("add", {content:$.xf.loading("正在加载菜单中...")});
            // //更新标题名称
            // $('.easyui-layout').layout('panel', 'west').panel({title: title});
          },
          success: function(data){
            $('#B_menubar').html('');
            var count = data.length;
            for(var i=0; i<count; i++)
            {

              $('#B_menubar').append("<dt><span data-id='7Admin'><i class='icon "+data[i]['icon']+"'></i>"+data[i]['text']+"</span></dt><dd style='display: block;' class="+data[i]['id']+"><ul></ul></dd>");
              var icount = data[i]['children'].length;
              // $('#B_menubar').append("<dd style='display: block;'><ul>");
              for(var s=0; s<icount; s++)
              {
                $('#B_menubar dd.'+data[i]['id']+' ul').append("<li><a href='"+data[i]['children'][s]['url']+"' data-top-id="+topid+" data-id='"+data[i]['children'][s]['id']+"'><i class='icon "+data[i]['children'][s]['icon']+"'></i>"+data[i]['children'][s]['text']+"</a></li>");
                // alert(data[i]['children'][s]['text']);
              }
              // $('#B_menubar').append("");
            }


          },
          error: function(){
            $('#B_menubar').html('<div class="loading" id="loading">菜单加载失败...</div>');
          }
        });

      }

    });
    $(".top-nav").eq(0).click();
    $('#B_menubar').on('click', 'a', function (e) {
        e.preventDefault();
        e.stopPropagation();
       // alert('111');
         ITENY.iframe_height();
        var $this = $(this),
        _dt = $this.parent(),
        _dd = _dt.next('dd');
        $("#B_menubar li").removeClass('current');
        //当前菜单状态
        _dt.addClass('current').siblings('dt.current').removeClass('current');
        //子菜单显示&隐藏
        if (_dd.length) {
            _dt.toggleClass('current');
            alert('111');
            _dd.toggle();
            //检查上下分页
            checkMenuNext();
            return false;
        };
        $('#loading').show().focus(); //显示loading
        $('#B_history li').removeClass('current');
        var data_id = $(this).attr('data-id');
        var data_top_id = $(this).attr('data-top-id');
            li = $('#B_history li[data-id=' + data_id + ']');
        var href = this.href;
        ITENY.iframeJudge({
            elem: $this,
            href: href,
            id: data_id,
            topid: data_top_id
        });
    });
    // //顶部点击一个tab页
    $('#B_history').on('click focus', 'li', function (e) {
        e.preventDefault();
        e.stopPropagation();
        var data_id = $(this).data('id');
        $(this).addClass('current').siblings('li').removeClass('current');
        try{
            var menuid = parseInt(data_id);
            if(menuid){
              setCookie("menuid",menuid);
            }
        }catch(err){}
        $('#iframe_' + data_id).show().siblings('iframe').hide(); //隐藏其它iframe
    });
    // /*
    //  * 搜索
    //  */
    var search_keyword = $('#J_search_keyword'),
        search = $('#J_search');
        search.on('click', function (e) {
        e.preventDefault();
        var $this = $(this),
            search_val = $.trim(search_keyword.val());
        if (search_val) {
            ITENY.iframeJudge({
                elem: $this,
                href: $('#J_search_keyword').attr('data') + '&keyword=' + search_val,
                id: 'search'
            });
        }
    });

    //回车搜索
    search_keyword.on('keydown', function (e) {
        if (e.keyCode == 13) {
            search.click();
        }
    });
    //顶部关闭一个tab页
    $('#B_history').on('click', 'a.del', function (e) {
        e.stopPropagation();
        e.preventDefault();
        var li = $(this).parent().parent(),
            prev_li = li.prev('li'),
            data_id = li.attr('data-id');
        li.hide(60, function () {
            $(this).remove(); //移除选项卡
            $('#iframe_' + data_id).remove(); //移除iframe页面
            var current_li = $('#B_history li.current');
            //找到关闭后当前应该显示的选项卡
            current_li = current_li.length ? current_li : prev_li;
            current_li.addClass('current');
            cur_data_id = current_li.attr('data-id');
            $('#iframe_' + cur_data_id).show();
        });
    });
    //刷新
    $('#J_refresh').click(function (e) {
        e.preventDefault();
        e.stopPropagation();
        var id = $('#B_history .current').attr('data-id'),
            iframe = $('#iframe_' + id);
        if (iframe[0].contentWindow) {
            //common.js
            ITENY.reloadPage(iframe[0].contentWindow);
        }
    });

    //全屏/非全屏
    $('#J_fullScreen').toggle(function (e) {
    	// alert('111');
        e.preventDefault();
        e.stopPropagation();
        $(document.body).addClass('fullScreen');
         def_iframe_height = $("body").height();
         $("#B_frame").height(def_iframe_height);
        }, function () {
            $(document.body).removeClass('fullScreen');
         ITENY.iframe_height();
    });

    //下一个选项卡
    $('#J_next').click(function (e) {
        e.preventDefault();
        e.stopPropagation();
        var ul = $('#B_history'),
            current = ul.find('.current'),
            li = current.next('li');
        ITENY.showTab(li);
    });

    //上一个选项卡
    $('#J_prev').click(function (e) {
        e.preventDefault();
        e.stopPropagation();
        var ul = $('#B_history'),
            current = ul.find('.current'),
            li = current.prev('li');
        ITENY.showTab(li);
    });
});


//增强体验，如果支持全屏，则使用更完美的全屏方案
/*
Wind.use('requestFullScreen', function () {
    if (fullScreenApi.supportsFullScreen) {
        $('#J_fullScreen').unbind('click').one('click', function (e) {
            e.preventDefault();
            $('body').requestFullScreen();
        });
    }
})
*/
</script>